import { ResponseResultStatus } from "../../business/ResponseResultStatus";
import { isEmptyForNumber, isEffectiveNumber } from "../../../util/common";

//@flow

export type Props = {
    code :number ,
    message:string,
    data:any
}

export class ResponseBaseModal {
    /**状态码 */
    _code: number;
    get code(): number {
        return this._code;
    }
    set code(value: number) {
        if(isEffectiveNumber(value)){
            this._code = value;
        }else{
            this._code = ResponseResultStatus.Fail;
        }
        
    }
    /**响应消息 */
    _message: string;
    get message(): string {
        return this._message;
    }
    set message(value: string) {
        if(value){
            this._message = value;
        }else{
            this._message = '请求出错~'
        }
        
    }
    /**响应数据 */
    _data: any;
    get data(): any {
        return this._data;
    }
    set data(value: any) {
        this._data = value;
    }
    /**构造函数 */
    constructor(props:Props){
        this.code = props.code 
        this.message = props.message 
        this.data = props.data;
    }
}
